//
//  BaseJourneyDetilViewController.m
//  Travel_M_Travel
//
//  Created by APPLE10 on 15-3-30.
//  Copyright (c) 2015年 lanou3g.com 蓝鸥科技. All rights reserved.
//

#import "BaseJourneyDetilViewController.h"

@interface BaseJourneyDetilViewController ()

@end

@implementation BaseJourneyDetilViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self addView];
    
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
    CGFloat yOffset   = self.scrollView.contentOffset.y;
    CGFloat xOffset   = self.wrapperScroll.contentOffset.x;
    
    if (yOffset < 0) {
        
        CGFloat pageWidth = self.wrapperScroll.frame.size.width;
        int page = floor((self.wrapperScroll.contentOffset.x - pageWidth / 2) / pageWidth) + 1;
        
        CGFloat factor = ((ABS(yOffset)+ ImageHeight )*ImageWidth)/ ImageHeight;
        
        CGRect f = CGRectMake((-(factor-ImageWidth)/2) + 320 *page, 20, ImageWidth, ImageHeight);
        f.size.height = ImageHeight+ABS(yOffset);
        f.size.width = factor;
        _imgProfile.frame = f;
        
        CGRect frame = self.imgContainer.frame;
        frame.origin.y = 0;
        self.imgContainer.frame = frame;
        
        
        
    } else {
        self.imgContainer.contentOffset = CGPointMake(xOffset, yOffset);
    }
    
    
    
    
}

- (void)addView
{
    self.imgContainer  = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, ImageWidth, self.view.bounds.size.height)];
    self.imgContainer.backgroundColor = [UIColor clearColor];
    self.imgContainer.contentSize = CGSizeMake(ImageWidth, self.view.bounds.size.height);
    
    [self.view addSubview:self.imgContainer];
    
    self.imgProfile = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, _imgContainer.frame.size.width, ImageHeight)];
    [self.imgContainer addSubview:self.imgProfile];
    
    UIView *detilView = [[UIView alloc] initWithFrame:CGRectMake(0, 100, self.view.frame.size.width, self.view.frame.size.height)];
    detilView.backgroundColor = [UIColor whiteColor];
    detilView.layer.cornerRadius = 10;
    detilView.clipsToBounds = YES;
    CGRect frame = detilView.frame;
    frame.origin.y = ImageHeight;
    detilView.frame = frame;
    
    self.scrollView = [[UIScrollView alloc] init];
    self.scrollView.delegate = self;
    self.scrollView.backgroundColor = [UIColor clearColor];
    self.scrollView.contentSize = CGSizeMake(320, detilView.frame.size.height+ImageHeight);
    [self.scrollView addSubview:detilView];
    [self.view addSubview:self.scrollView];
    
    CGRect backFram =CGRectMake(0, 5, 50, 50);
    UIButton *backBtu = [UIButton buttonWithTitle:@"<" frame:backFram target:self action:@selector(backBtuAction:)];
    backBtu.backgroundColor = [UIColor whiteColor];
    backBtu.layer.cornerRadius = 50;
    backBtu.alpha = 0.5;
    [self.view addSubview:backBtu];
    
}

#pragma  mark MoreBtu
- (void)ratingBtuAction : (UIButton *)btu
{
    NSLog(@"111");
}

#pragma mark backBtu
- (void)backBtuAction: (UIButton *)btu
{
    
}


- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
    
}



/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end
